package o;

import android.util.Pair;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.extractor.flv.TagPayloadReader;
import com.google.android.exoplayer2.extractor.flv.TagPayloadReader.UnsupportedFormatException;
import com.huawei.hms.support.api.entity.core.JosStatusCodes;
import java.util.Collections;

final class aee extends TagPayloadReader {
    private static final int[] ˋ = new int[]{5512, 11025, 22050, 44100};
    private boolean ˊ;
    private int ˎ;
    private boolean ॱ;

    public aee(aef o_aef) {
        super(o_aef);
    }

    public boolean ॱ(anc o_anc) throws UnsupportedFormatException {
        if (this.ॱ) {
            o_anc.ˎ(1);
        } else {
            int ʽ = o_anc.ʽ();
            this.ˎ = (ʽ >> 4) & 15;
            if (this.ˎ == 2) {
                this.ˏ.ˎ(Format.ˎ(null, "audio/mpeg", null, -1, -1, 1, ˋ[(ʽ >> 2) & 3], null, null, 0, null));
                this.ˊ = true;
            } else if (this.ˎ == 7 || this.ˎ == 8) {
                this.ˏ.ˎ(Format.ˋ(null, this.ˎ == 7 ? "audio/g711-alaw" : "audio/g711-mlaw", null, -1, -1, 1, JosStatusCodes.RTN_CODE_COMMON_ERROR, (ʽ & 1) == 1 ? 2 : 3, null, null, 0, null));
                this.ˊ = true;
            } else if (this.ˎ != 10) {
                throw new UnsupportedFormatException("Audio format not supported: " + this.ˎ);
            }
            this.ॱ = true;
        }
        return true;
    }

    public void ˊ(anc o_anc, long j) throws ParserException {
        if (this.ˎ == 2) {
            int ˊ = o_anc.ˊ();
            this.ˏ.ˎ(o_anc, ˊ);
            this.ˏ.ˋ(j, 1, ˊ, 0, null);
            return;
        }
        int ʽ = o_anc.ʽ();
        if (ʽ == 0 && !this.ˊ) {
            byte[] bArr = new byte[o_anc.ˊ()];
            o_anc.ˎ(bArr, 0, bArr.length);
            Pair ˋ = amr.ˋ(bArr);
            this.ˏ.ˎ(Format.ˎ(null, "audio/mp4a-latm", null, -1, -1, ((Integer) ˋ.second).intValue(), ((Integer) ˋ.first).intValue(), Collections.singletonList(bArr), null, 0, null));
            this.ˊ = true;
        } else if (this.ˎ != 10 || ʽ == 1) {
            ˊ = o_anc.ˊ();
            this.ˏ.ˎ(o_anc, ˊ);
            this.ˏ.ˋ(j, 1, ˊ, 0, null);
        }
    }
}
